﻿using FluentMigrator;
using FluentMigrator.Builders.Create.Table;
using Rubikev.Rockface.Core.Entities;

namespace Rubikev.Rockface.Database.Tables
{
   /// <summary>
   /// Creates the resource table
   /// </summary>
   [Migration(201106051912)]
   public class CreateResourceTable : CreateTableMigration
   {
      /// <summary>
      /// The name of the resource table
      /// </summary>
      public override string TableName
      {
         get { return "Resource"; }
      }

      /// <summary>
      /// Creates the Id and Type columns
      /// </summary>
      /// <param name="table">The resource table</param>
      protected override void CreateColumns(ICreateTableWithColumnOrSchemaSyntax table)
      {
         table
            .WithColumn("Id").AsInt32().PrimaryKey().Identity()
            .WithColumn("Location").AsString(Resource.MaxUriLength)
            .WithColumn("Type").AsString(1);
      }
   }
}
